home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.3 / IEEE / src / div0 / aztec / trapasm.asm < prev    next >
Encoding:
Assembly Source File  |  1992-08-27  |  1.0 KB  |  42 lines

  1.  
  2.     include    'exec/types.i'
  3.     include    'exec/tasks.i'
  4.  
  5.     xref    _localf
  6.     xref    _oldtraphandler
  7. *    csect    text
  8. *    localf is a table of user trap handlers
  9.     xdef    _trapintercept
  10. _trapintercept:
  11. *    called from exec with the following on the stack
  12. *    (sp).w    = trap#        8
  13. *    (sp).w  = 0
  14. *    (sp).w  = sr        12
  15. *    (sp).l  = pc        14
  16. *    other processor dependant gunk
  17. *    We are in supervisor mode
  18. *    all we want to do is check to see if this trap is one
  19. *    we want to handle, if so, rte to correct handler
  20. *    else let other trap handler deal with it.
  21.     movem.l    d0/a0,-(sp)    ; need a data register
  22. *    4(sp) -> ap
  23.     move.l    8(sp),d0    ; get trap number
  24.     asl.l    #2,d0        ; convert in array index
  25.     lea    _localf,a0
  26.     move.l    0(a0,d0.l),d0    ; get alternate usermode vector
  27.     if <>
  28. ;        ; -1 means ignore trap and just rte
  29.         if #-1<>d0.l
  30.             move.l    d0,14(sp)    ; modify rte address
  31.         endif
  32.         movem.l    (sp)+,d0/a0    ; restore d0/a0, why?
  33.         addq.l    #4,sp        ; remove trap #
  34.         rte            ; close eyes, plug ears
  35.     endif
  36. *    take original trap
  37.     movem.l    (sp)+,d0/a0    ;restore d0 contents
  38.     move.l    _oldtraphandler,-(sp)
  39.     rts            ; jump to it
  40.  
  41.     end
  42.